
import { list, deleteByIds, queryEnable, create, queryById, change } from '@/api/domain'
const getDefaultState = () => {
  return {

  }
}

const state = getDefaultState()

const mutations = {

}

const actions = {
  /**
   * 创建区域
   * @param {*} domainForm 区域数据
   */
  create({ commit }, domainForm) {
    return new Promise(function (resolve, reject) {
      create(domainForm).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 修改区域
   * @param {*} domainForm 区域数据
   */
  modifyById({ commit }, domainForm) {
    return new Promise(function (resolve, reject) {
      change(domainForm).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 查询域列表
   * @param {*} searParams 检索数据
   */
  list({ commit }, searParams) {
    return new Promise(function (resolve, reject) {
      list(searParams).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 通过id删除区域
   * @param {*} domainIds 区域id
   */
  removeByIds({ commit }, domainIds) {
    return new Promise(function (resolve, reject) {
      deleteByIds(domainIds).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 查询区域启用状态
   */
  getEnable() {
    return new Promise(function (resolve, reject) {
      queryEnable().then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  },
  /**
   * 通过id查询区域
   */
  getById({ commit }, domainId) {
    return new Promise(function (resolve, reject) {
      queryById(domainId).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
